import service from "./service";
//声明一个基础接口变量
let baseURL: string;

//配置开发环境
if (process.env.NODE_ENV === "development") {
  baseURL = "http://192.168.0.100:5050";
}

// 配置生产环境
if (process.env.NODE_ENV === "production") {
  baseURL = "http://192.168.0.100:5050";
}
//设置请求头（如果请求头统一的话可以在axios文件设置，则无须从这里传过去）
const headers = {
  // Accept: "application/json;charset=UTF-8",
  "Content-Type": "application/json",
};

//根据自身需求
const _service = {
  getList(data: any) {
    const url = baseURL + "/api/list";
    return service.get(url, data, headers);
  },
  getDetail(data: any) {
    const url = baseURL + "/api/detail";
    return service.get(url, data, headers);
  },
  createItem(data: any) {
    const url = baseURL + "/api/add";
    return service.put(url, data, headers);
  },
  updateItem(data: any) {
    const url = baseURL + "/api/update";
    return service.post(url, data, headers);
  },
  deleteItem(data: any) {
    const url = baseURL + "/api/delete";
    return service.delete(url, data, headers);
  },
};

//导出
export default _service;
